package cate.game.play.config.enhance;

import cate.common.table.fight.skill.row.SkillEnhanceRow;
import cate.game.play.support.PlayBuildContext;
import cate.game.table.TableManager;
import easy.java.dev.note.NoteClass;

import java.util.HashMap;
import java.util.Map;

@NoteClass("技能强化配置")
public class SkillEnhanceHolder {

    private Map<Integer, SkillEnhanceCfg> map = new HashMap<>();

    public SkillEnhanceCfg get(int id) {
        return map.get(id);
    }

    public void init(TableManager table) {
        map.clear();
        table.skill.enhance.getList().forEach(this::create);
    }

    public void init(PlayBuildContext context) {
        map.clear();
        context.skillExcel().enhance.getList().forEach(this::create);
    }

    private void create(SkillEnhanceRow row){
        SkillEnhanceCfg cfg = new SkillEnhanceCfg().init(row);
        map.put(cfg.id, cfg);
    }
}
